﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace HHHFramework
{
    public class ResMgr : Singleton<ResMgr>
    {
        private ResMgr() {

        }
#if UNITY_EDITOR
        private const string kSimulationModeKey = "simulation mode";
        private static int mSimulationMode = -1;
        public static bool SimulationMode
        {
            get {
                if (mSimulationMode==-1) {
                    mSimulationMode = UnityEditor.EditorPrefs.GetInt(kSimulationModeKey, 1);
                }

                return mSimulationMode!=0;
            }
            set {
                mSimulationMode = value ? 1 : 0;
                UnityEditor.EditorPrefs.SetInt(kSimulationModeKey, mSimulationMode);
            }
        }
        

#endif
        public static bool IsSimulationModelogic {
            get {
#if UNITY_EDITOR
                return SimulationMode;
#endif
                return false;
            }
        }


        public List<Res> sharedLoadRes = new List<Res>();
#if UNITY_EDITOR
        private bool showLog = true;

        private void OnGUI()
        {
            if (GUILayout.Button("ResLog")) { showLog = !showLog; }

            if (showLog)
            {
                GUILayout.BeginVertical("box");
                sharedLoadRes.ForEach(resload => {
                    GUILayout.Label($"Name:{resload.AssetName}  ,ResState:{resload.State}  RefCount:{resload.RefCount}");
                });
                GUILayout.EndVertical();
            }

        }

        
#endif
    }
}